'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 科技信息
 * @author sundbcn@gmail.com (sun debing)
 */

var moment = require('moment');
var modelUtil = require('../util/modelUtil');
var mongoConnector = require('../libs/mongodb/mongoConnector');
var techSchema = require('../schemas/tech/techSchema');
var techService = require('../services/techService');
var Tech = mongoConnector().model('Tech');

/**
 * 根据角色id获取科技数据，同时刷新科技队列
 * @param  {[type]} role_id [description]
 * @param  {[type]} cb [description]
 * @return {[type]}     [description]
 */
module.exports.getByRoleId = function (role_id, cb) {
    modelUtil.getByRoleId(Tech, role_id, function (err, tech_model) {
        if (!!err) {
            console.error(err);
            return cb(err);
        }

        cb(err, tech_model);
    });
};

/**
 * 刷新数据
 */
module.exports.onRefreshData = function (self, cb) {
    techService.refreshQue(self, false, cb);
};

/**
 * 获取多个玩家的建筑数据
 */
module.exports.findTeches = function (where, cb) {
    Tech.find(where, cb);
};
